import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { CustomerCustomerEntity } from '../../entity/customer';
import { CustomerCustomerService } from '../../service/customer';
import { BaseSysUserEntity } from '../../../base/entity/sys/user';

/**
 * 客户信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: CustomerCustomerEntity,
  service: CustomerCustomerService,
  pageQueryOp: {
    keyWordLikeFields: ['a.name', 'a.phone'],
    fieldEq: ['a.country', 'a.industry', 'a.level', 'a.userId'],
    join: [
      {
        entity: BaseSysUserEntity,
        alias: 'b',
        condition: 'a.userId = b.id',
        type: 'leftJoin',
      },
    ],
    select: ['a.*', 'b.nickName as userName'],
  },
})
export class AdminCustomerCustomerController extends BaseController {
  @Inject()
  customerCustomerService: CustomerCustomerService;
}
